1 <?php
2  session_start();
3  
if(isset($_SESSION['user']))
4  {
5
6  }
7  
else{
8   echo
"<script>location.href='login.html'</script>";
9  }
10 ?>
11 <!doctype html>
12 <html>
13 <head>
14         <title>Petproducts </title>
15         <style>
16   body {
17   margin:
0;
18   font-family: Arial, Helvetica, sans-serif;
19   background: #
484848;
20 }
21 .topnav {
22   overflow: hidden;
23   background-color: #f44336;
24   height: 70px;
25   border: 3px solid #ff0000;
26 }
27
28 .topnav a {
29   
float: left;
30   color: #f2f2f2;
31   text-align: center;
32   padding: 14px 16px;
33   text-decoration: none;
34   font-size: 35px;
35   font-weight: bold;
36 }
37
38 .topnav-right {
39   
float: right;
40 }
41 fieldset {
42   background: #FAFAFA;
43     padding: 10px;
44    margin:auto;
45    max-width:450px;
46     box-shadow: 1px 1px 25px rgba(
0, 0, 0, 0.35);
47     border-radius: 10px;
48     border: 6px solid #f44336;
49
50
51 }
52
53     </style>
54 </head>
55 <body>
56 <div
class="topnav">
57             <a
class="active" href="home.html"><img src="ic_add_pet.png"></a>
58             <a href=
"petproducts.php">pets products</a>
59             <div
class="topnav-right">
60               <a href=
"logout.php">logout</a>
61             </div>
62           </div>
63     <form>
64         <button type=
"submit" formaction="petproducts.php" style="margin:15px;height: 30px;width: 100px;
65         cursor:pointer;border-radius:15px;
66 border: 3px solid #ff0000;background-color:#f44336;color:#f2f2f2;font-size:17px;"
>back</button>
67 </form>
68 <form method=
"post" action="productsadd.php">
69 <fieldset>
70    <input type=
"text" name="id" placeholder=" Enter product_id" style="width:100%;height:30px;
71    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
72   <br><br>
73   <input type=
"text" name="name" placeholder=" Enter product name" style="width:100%;height:30px;
74    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
75   <br><br>
76    <input type=
"text" name="type" placeholder=" Enter product type" style="width:100%;height:30px;
77    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
78   <br><br>
79   <input type=
"number" name="cost" placeholder=" Enter cost" style="width:100%;height:30px;
80    border: 2px solid #f44336; border-radius:3px; background:transparent;"
min="0" required>
81   <br><br>
82   <input type=
"text" name="belong" placeholder=" which pet category it belongs to" style="width:100%;height:30px;
83    border: 2px solid #f44336; border-radius:3px; background:transparent;"
required>
84   <br><br>
85   <input type=
"submit" name="submit" value="save" placeholder=" which pet category it belongs to" style="width:100%;height:30px;
86    border: 2px solid #f44336; border-radius:3px; cursor:pointer;background-color:#f44336"
>&ensp;
87 </fieldset>
88 </form>
89 </body>
90 </html>
91 <?php

92 if
(isset($_POST["submit"]))
93 {

94 // define variables and
set to empty values
95 $servername =
"localhost";
96 $username =
"root";
97 $password =
"";
98 $dbname =
"Petshop_management";
99
100 // Create connection

101 $conn =
new mysqli($servername, $username, $password, $dbname);
102 // Check connection

103 if
($conn->connect_error) {
104     die(
"Connection failed: " . $conn->connect_error);
105 }

106 //echo
" CONNECTION ESTABLISHED \r\n";
107 //echo
" INSERTION IN PROCESS";
108 $id = $_POST[
"id"];
109   $name = $_POST[
"name"];
110   $type= $_POST[
"type"];
111   $belongs = $_POST[
"belong"];
112   $cost = $_POST[
"cost"];
113
114
115
116
117 $sql =
"INSERT INTO pet_products( pp_id,pp_name,pp_type,cost,belongs_to)
118 VALUES ('$id','$name','$type','$cost','$belongs')"
;
119 if
($conn->query($sql) == TRUE) {
120   echo
'<div>
121   <h1 style=
"color:#f2f2f2;font-size:20px; font-family: "Roboto", sans-serif;margin:auto;">New record of id='
122   .$id.
' inserted successfully</h1>
123      </div>
';
124 }
else {
125     echo
"Error: " . $sql . "<br>" . $conn->error;
126 }
127
128 $conn->close();
129 }
130 ?>


Gõ tìm kiếm nhanh...